import {
getSalaryCalculationEmpList,
synchronizeAttendanceData,
removeEmp,
calculation,
updateCalculation
} from "@/api/salary/salaryCalculation";

export default (await import('vue')).defineComponent({
components: { importModal },
props: {
salaryCalculationForm: {
type: Object,
default() {
return {};
},
},
},
dicts: [],
data() {
return {
// 遮罩层
loading: true,
// 总条数
total: 0,
tableColumn: [],
tableList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
},
form: {
dataList: [],
},
rules: {},
};
},
created() {
this.getList();
},
methods: {
getList() {
getSalaryCalculationEmpList({
...this.queryParams,
salaryCalculationId: this.salaryCalculationForm.id,
type: 1
}).then((res) => {
this.tableColumn = res.data.headerList.map((item) => {
return {
title: item,
};
});
let list = JSON.parse(JSON.stringify(res.data.empInfoList));
判断数据中第几项后是需要动态改变颜色的数据;
list.forEach((item) => {
var flag = item.dataList.findIndex(item => {
return item === '============';
});
item.dataList.splice(flag, 1);
item.dataList.forEach((ele, index) => {
if (index > (flag - 1)) {
if (typeof ele != 'object') {
if ((ele.indexOf('(true)') != -1)) {
item.dataList[index] = {
projectDataSourceValue: ele.split('(')[0],
ifChange: 1
};
}
else {
item.dataList[index] = {
projectDataSourceValue: ele.split('(')[0],
ifChange: 2
};
}
}
}
});
});
this.tableList = list;
this.loading = false;
});
},
/** 运算/重新运算 */
handleOperation() {
this.$modal
.confirm(this.$t("calculation_salary"))
.then(() => {
calculation(this.salaryCalculationForm.id).then((res) => {
this.$modal.msgSuccess(this.$t("operation_successful"));
this.getList();
this.$emit("operationFinish", this.salaryCalculationForm);
});
})
.catch(() => { });
},
/** 同步数据 */
handleSyncData() {
this.$modal
.confirm(this.$t("synchronize_attendance_data"))
.then(() => {
synchronizeAttendanceData(this.salaryCalculationForm.id).then(
(res) => {
this.$modal.msgSuccess(this.$t("operation_successful"));
this.getList();
}
);
})
.catch(() => { });
},
/** 修改 */
handleUpdate(row) {
this.title = this.$t("modify");
this.open = true;
this.form = { ...row };
},
/** 删除 */
handleDelete(row) {
this.$modal
.confirm(this.$t("delete_data"))
.then(function () {
return removeEmp(row.salaryCalculationEmpId);
})
.then(() => {
this.getList();
this.$modal.msgSuccess(this.$t("operation_successful"));
})
.catch(() => { });
},
cancel() {
this.open = false;
},
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {

this.$confirm(this.$t("edit_dialog"), this.$t("prompt"), {
type: "warning",
}).then((res) => {
let list = this.form.dataList.filter((item) => {
return Object.prototype.toString.call(item) === "[object Object]";
});
let attendanceDaysIndex = this.tableColumn.findIndex((item) => {
return item.title == this.$t("attendance_days");
});
updateCalculation({
salaryCalculationId: this.salaryCalculationForm.id,
salaryCalculationEmpId: this.form.salaryCalculationEmpId,
empProjectResultList: list,
attendanceDays: this.form.dataList[attendanceDaysIndex].projectDataSourceValue,
}).then((response) => {
this.$modal.msgSuccess(this.$t("operation_successful"));
this.open = false;
this.getList();
});
});
}
});
},
/** 导出 */
handleExport() {
this.download(
"salary/salaryCalculation/3downloadTemplate.do",
{ salaryCalculationId: this.salaryCalculationForm.id },
`salaryCalculation_${new Date().getTime()}.xlsx`
);
},
/** 导入 */
handleImport() {
this.$refs.importModal.showModal();
},
//上一步
preStep() {
this.$emit("changeStatus", 1);
},
//下一步
nextStep() {
this.$emit("changeStatus", 4);
},
},
});
